#coding: utf-8
name = 'bob'
password = '12345678'
num = 3

while True:
    user = input('please input your username: ')
    passwd = input('please input your password:')
    if user.isalpha():
        if user == name and passwd == password:
            print('login success!')
            break
        else:
            print('login failed, username or password wrong!')
            num -= 1
            continue
    else:
        print('the username must be letter!')
        break


# 这里 num可以作为while的条件，更符合逻辑
